package com.keli.dt.model.bpss;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

import com.keli.dt.model.LaneReport;

public class LaneReportDeleteBPSS implements BatchPreparedStatementSetter {
	private List<LaneReport> laneReports;
	
	public LaneReportDeleteBPSS(List<LaneReport> laneReports) {
		this.laneReports = laneReports;
	}
	
	public static String deleteSql() {
		StringBuffer sql = new StringBuffer();
		sql.append("DELETE FROM DT_LANE_REPORT_R WHERE DETECT_CLASS = ? AND DETECT_ID = ? AND ");
		sql.append("ROAD_ID = ? AND LANE = ?");
		
		return sql.toString();
	}

	@Override
	public void setValues(PreparedStatement ps, int i) throws SQLException {
		LaneReport lr = laneReports.get(i);
		int j = 1;
		ps.setString(j++, lr.getDETECT_CLASS());
		ps.setString(j++, lr.getDETECT_ID());
		ps.setString(j++, lr.getROAD_ID().toString());
		ps.setString(j++, lr.getLANE());
	}

	@Override
	public int getBatchSize() {
		return laneReports.size();
	}

}
